<template>
  <view class="wrap">
    <uv-navbar leftText="" fixed title="更多" safeAreaInsetTop placeholder autoBack bgColor='#FFF' leftIconColor='#333' :titleStyle="{color: '#333'}">
      <!-- <template v-slot:right>
        <view class="uv-nav-slot">
          <uv-icon size="40rpx" color="#333" name="plus-circle"></uv-icon>
        </view>
      </template> -->
    </uv-navbar>
    <view class="couser">
      <view class="title">{{ body.name }}</view>
      <view class="desc">群号：{{ body.id }}</view>
    </view>
    <view class="user" v-if="body.member_info && body.member_info.user">
      <view class="left">
        <avatar :src="body.member_info.user.avatar" styles="width: 70rpx;height: 70rpx;"></avatar>
        <view class="name">
          <view class="nick">{{ body.member_info.user.nickname }}</view>
          <view class="desc" v-if="body.member_info.expiretime">
            <text>有效期：{{ timeFormat(body.member_info.expiretime) }}</text>
            <view class="xu" @click="openRenew">
              <text>续费</text>
              <uv-icon name="arrow-right" color="#999999" size="28rpx"></uv-icon>
            </view>
          </view>
        </view>
      </view>
      <template v-if="body.member_info">
        <view class="right" v-if="body.member_info.identity == 1 || body.member_info.identity == 2 || body.member_info.identity == 3" :class="peopleColor[body.member_info.identity]">{{peopleType[body.member_info.identity]}}</view>
      </template>
    </view>
    <view class="list">
      <uv-cell-group>
        <uv-cell title="编辑群组资料" :value='body.name' url='/pages/group/setting/edit' center isLink :border="false" titleStyle='font-weight: 500; font-size: 32rpx; color: #2B2B2B;' cellStyle='background-color: #FFF' v-if="body.member_info.identity == 1"></uv-cell>
        <uv-cell title="社群成员" :value="body.member_count + '人'" url='/pages/group/setting/member' center isLink :border="false" titleStyle='font-weight: 500; font-size: 32rpx; color: #2B2B2B;' cellStyle='background-color: #FFF'></uv-cell>
        <uv-cell title="社群管理" value='' url='/pages/group/setting/manage' center isLink :border="false" titleStyle='font-weight: 500; font-size: 32rpx; color: #2B2B2B;' cellStyle='background-color: #FFF' v-if="body.member_info.identity == 1"></uv-cell>
        <uv-cell title="社群分成比例设置" value='' url='/pages/group/setting/divided' center isLink :border="false" titleStyle='font-weight: 500; font-size: 32rpx; color: #2B2B2B;' cellStyle='background-color: #FFF' v-if="body.member_info.identity == 1"></uv-cell>
      </uv-cell-group>
    </view>
    <view class="list">
      <uv-cell-group>
        <uv-cell title="话题管理" url='/pages/group/setting/topic' center isLink :border="false" titleStyle='font-weight: 500; font-size: 32rpx; color: #2B2B2B;' cellStyle='background-color: #FFF' v-if="body.member_info.identity == 1 || body.member_info.identity == 2"></uv-cell>
        <uv-cell title="社群专栏" url='/pages/group/setting/column' center isLink :border="false" titleStyle='font-weight: 500; font-size: 32rpx; color: #2B2B2B;' cellStyle='background-color: #FFF' v-if="body.member_info.identity == 1 || body.member_info.identity == 2"></uv-cell>
      </uv-cell-group>
    </view>
    <view class="list">
      <uv-cell-group>
        <uv-cell title="邀请合伙人" :value="body.member_partner_count + '/20'" url='' center isLink :border="false" titleStyle='font-weight: 500; font-size: 32rpx; color: #2B2B2B;' cellStyle='background-color: #FFF' v-if="body.member_info.identity == 1"></uv-cell>
        <uv-cell title="邀请嘉宾" :value="body.member_guest_count + '/80'" url='' center isLink :border="false" titleStyle='font-weight: 500; font-size: 32rpx; color: #2B2B2B;' cellStyle='background-color: #FFF' v-if="body.member_info.identity == 1 || body.member_info.identity == 2"></uv-cell>
      </uv-cell-group>
    </view>
    <view class="list">
      <uv-cell-group>
        <uv-cell title="退出社群" url='' center isLink :border="false" titleStyle='font-weight: 500; font-size: 32rpx; color: #E43222;' cellStyle='background-color: #FFF' @click="outColumn" v-if="body.member_info.identity != 1"></uv-cell>
      </uv-cell-group>
    </view>
    
    <uv-modal ref="modal" title="提示" showCancelButton :closeOnClickOverlay="false" confirmColor='#E43222' @confirm="confirm" @cancel='cancel'>
      <view style="text-align: center;">
        是否确认退出社群
      </view>
    </uv-modal>
  </view>
</template>

<script setup>
import { ref, computed } from 'vue';
import { toast, getGroup } from '@/common';
import { useOrder } from '@/store';
import { post } from '@/api';
import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js';

const modal = ref(null);
const peopleType = { 1: '群主', 2: '合伙人', 3: '嘉宾' };
const peopleColor = { 1: 'red', 2: 'yellow', 3: 'blue' };

let body = computed(() => {
  const store = useOrder();
  return uni.$uv.deepClone(store.group);
});

function openRenew(){
  uni.navigateTo({
    url: `/pages/group/cashier`
  });
}
function confirm(){
  uni.navigateTo({
    url: `/pages/group/setting/out?id=${body.value.id}`
  });
}
function outColumn(){
  modal.value.open();
}
function cancel(){
  modal.value.close();
}
</script>

<style lang="scss" scoped>
  .list{
    margin-top: 20rpx;
    :deep(.uv-cell__value){
      font-weight: 400;
      font-size: 28rpx;
      color: #999999;
    }
    :deep(.uv-line){
      display: none;
    }
  }
  .user{
    padding: 0 30rpx;
    margin-top: 20rpx;
    background-color: #fff;
    height: 120rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .right{
      width: 111rpx;
      height: 68rpx;
      line-height: 68rpx;
      border-radius: 68rpx;
      font-weight: 400;
      font-size: 24rpx;
      color: #FFFFFF;
      text-align: center;
      &.red{
        background-color: #E43222;
      }
      &.yellow{
        background-color: #F0BA16;
      }
      &.blue{
        background-color: #465B89;
      }
    }
    .left{
      display: flex;
      align-items: center;
      .name{
        padding-left: 28rpx;
        .desc{
          font-size: 24rpx;
          color: #999999;
          display: flex;
          align-items: center;
          .xu{
            display: flex;
            align-items: center;
            margin-left: 20rpx;
          }
        }
        .nick{
          font-weight: 500;
          font-size: 32rpx;
          color: #2B2B2B;
        }
      }
    }
  }
  .couser{
    padding: 60rpx 50rpx;
    background-color: #fff;
    .desc{
      font-weight: 400;
      font-size: 28rpx;
      color: #999999;
    }
    .title{
      font-weight: 600;
      font-size: 48rpx;
      color: #2B2B2B;
    }
  }
  .wrap{
    width: 100%;
    min-height: 100vh;
    background-color: #F0F0F0;
  }
</style>